<?php
namespace modules\admin;

use mytp\Captcha;
use modules\admin\model\Admin as AdminModel;
class Admin {
  protected $captcha;
  protected $code;
  protected $admin;

  public function __construct(Captcha $captcha, AdminModel $admin) {
    $this->captcha = $captcha;
    $this->admin = $admin;
  }

  public function captcha() {
    $this->code = $this->captcha->create();
    return [$this->captcha->show($this->code), 200, ["Content-Type" => "image/png", "code" => $this->code]];
  }

  public function success($res) {
    // $data = $this->admin->where('admin_name', $res['name'])->where('admin_pwd', $res['pwd'])->get();
    // var_dump($data);
    return $this->admin->where('admin_name', $res['name'])->where('admin_pwd', $res['pwd'])->get();
  }

}
?>